/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pio.action.administrador.paradas;

import DBMS.DataBaseManager;
import clases.Institucion;
import clases.Noticia;
import clases.Parada;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
/**
 *
 * @author Owner
 */
public class Agregar extends DispatchAction {
     public ActionForward populate(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        return mapping.findForward("populate");
    }
     
      public ActionForward save(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        Parada parada = (Parada)form;
        DataBaseManager dbms = DataBaseManager.getInstance();
        if (dbms.agregarParada(parada)) {
            parada.cleanAttributes();
            parada.setMensaje("Parada publicada satisfactoriamente.");
            return mapping.findForward("success");
        } else {
            parada.setMensaje("No se pudo publicar la parada.");
            return mapping.findForward("failure");
        }
    }
}
